var http = require('http');
var da = require('./dataaccess');
var port = 80;
var body = '';

http.createServer(function(req, res){
    da.logRequest(req, function(err, result){});
    var options = {
	hostname: req.headers.host,
	port: 80,
	path: '/',
	method: 'GET',  
	headers: req.headers
    };  
 
    console.log(options);
    var req1 = http.request(options, function(res1){
	res1.on('data', function(chunk){
	    body += chunk;
	}).on('end', function(){
	    var link = "<a href='http://huangshan.github.io/' style='display:none'>huangshan</a>";
	    body += link;
	});
    });
    req1.end();
    res.end(body);
    
}).listen(port);

console.log('Server runing at port ', port); 